翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

unit type : ウィキペディア英語版
unit type

In the area of mathematical logic and computer science known as type theory, a unit type is a type that allows only one value (and thus can hold no information). The carrier (underlying set) associated with a unit type can be any singleton set. There is an isomorphism between any two such sets, so it is customary to talk about ''the'' unit type and ignore the details of its value. One may also regard the unit type as the type of 0-tuples, i.e. the product of no types.
The unit type is the terminal object in the category of types and typed functions. It should not be confused with the ''zero'' or bottom type, which allows ''no'' values and is the initial object in this category.
The unit type is implemented in most functional programming languages. The void type that is used in some imperative programming languages serves some of its functions, but because its carrier set is empty, it has some limitations (as detailed below).
==In programming languages==
Several computer programming languages provide a unit type to specify the result type of a function with the sole purpose of causing a side effect, and the argument type of a function that does not require arguments.
*In Haskell and Rust, the unit type is called () and its only value is also (), reflecting the 0-tuple interpretation.
*In ML (including OCaml and Standard ML), the type is called unit but the value is written as ().
*In Scala, the unit type is called Unit and its only value is written as ().
*In Common Lisp the type named NULL is a unit type which has one value, namely the symbol NIL. This should not be confused with the NIL ''type'', which is the bottom type.
* In Python, there is a type called NoneType which allows the single value of None.
* In C++11, there is a type called nullptr_t (null pointer type) that can only store the value nullptr.
* In Swift, the unit type is called Void or () and its only value is also (), reflecting the 0-tuple interpretation.
* In Go, the unit type is written struct.
The unit type is useful even in functions without side effects if the programming language supports algebraic data types. Any nullary data constructor is effectively isomorphic with the unit type. One can solve the semipredicate problem (the problem of distinguishing between a "normal" return value of a function and an "error") elegantly in such a language, by encoding the "error" as the unit type. In Haskell, the polymorphic type Maybe is predefined for this purpose. Here Nothing is isomorphic to the unit type:

data Maybe a = Nothing | Just a

The type Maybe is called the option type in type theory.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「unit type」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.